class Solution {
public:
    int ret;
    int path;
    int target;
    int findTargetSumWays(vector<int>& nums, int _target) {
        target = _target;
        dfs(0, nums, path);
        return ret;
    }
    void dfs(int pos, vector<int>& nums, int path) {
        if (pos == nums.size()) {
            if (path == target) {
                ret++;
            }
            return;
        }
        dfs(pos + 1, nums, path + nums[pos]);
        dfs(pos + 1, nums, path - nums[pos]);
    }
};